#include "StdAfx.h"

#include "ProcParamDouble.h"
#include <iostream>
#include <sstream>

ProcParamDouble::ProcParamDouble(int Index, const char *Name, IPluginICProcStepsParam::Direction dir, double Value): 
	ProcParam(Index, Name, dir),
	_val(Value)
{
}

ProcParamDouble::ProcParamDouble(const ProcParamDouble *param) : 
	ProcParam(param)
{
	if (param != '\0')
		_val = param->_val;
}

ProcParamDouble::~ProcParamDouble(void)
{
}

long MXSTDMETHOD ProcParamDouble::DestroyPtr(void)
{
	long cnt = InterlockedDecrement(&_refCnt);
	if ( cnt == 0 )
		delete this;
	return cnt;
}

long MXSTDMETHOD ProcParamDouble::DuplicatePtr(void)
{
	return InterlockedIncrement(&_refCnt);
}

void *MXSTDMETHOD ProcParamDouble::Dynamic_cast(const char *IId)
{
	void *rc = '\0';

	if (IId != '\0')
	{
		if (strncmp (IPluginICProcStepsParamDoubleIID::GUID(), IId, IMxPluginBaseIID::IIdSize) == 0)
			rc = static_cast<IPluginICProcStepsParamDouble *>(this);
		else if (strncmp (IMxPluginBaseIID::GUID(), IId, IMxPluginBaseIID::IIdSize) == 0)
			rc = static_cast<IMxPluginBase *>(this);
		else
			rc = '\0';

		if (rc != '\0')
			((IMxPluginBase *)rc)->DuplicatePtr();
	}
	return rc;
}


void ProcParamDouble::SetValue(double Val)
{ 
	_val = Val; 

	std::stringstream ss (std::stringstream::in | std::stringstream::out);
	ss << Val;
	_valStr = ss.str();

}

//-------------------------------------------------------------------------------------------------
//			E N D   O F   F I L E
//-------------------------------------------------------------------------------------------------

